import { PureComponent } from "react"

export function logRenderTime(OriginComponent: React.ComponentType) {
  return class newComponent extends PureComponent {
    public beginTime!: number;
    public endTime!: number;
    UNSAFE_componentWillMount() {
      this.beginTime = Date.now()
    }
    componentDidMount() {
      this.endTime = Date.now()
      console.log(`花费${this.endTime - this.beginTime}ms渲染完成`);
    }
    render() {
      return <OriginComponent />
    }
  }
}

